﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>SoundSetMute - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The SoundSetMute function changes a mute setting of a sound device." />
<meta name="ahk:equiv-v1" content="lib/SoundSet.htm" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>SoundSetMute</h1>

<p>更改声音设备的静音设置.</p>

<pre class="Syntax"><span class="func">SoundSetMute</span> NewSetting <span class="optional">, Component, Device</span></pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>NewSetting</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#numbers">数字</a>或<a href="../Concepts.htm#strings">字符串</a></p>
    <p>任何正数都将打开设置(静音), 0 将关闭设置(不静音). 但是, 如果数字以加号或减号开头, 则设置将被切换(设置为与当前状态相反的状态).</p>
  </dd>

  <dt>Component</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a>或<a href="../Concepts.htm#numbers">整数</a></p>
    <p>组件的显示名称和/或索引. 例如, <code>1</code>, <code>"Line in"</code> 或 <code>"Line in:2"</code>.</p>
    <p>如果省略或为空, 则更改主静音设置.</p>
    <p>有关详情, 请参阅 <a href="Sound.htm#component">Component (Sound 函数)</a>.</p>
  </dd>

  <dt>Device</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a>或<a href="../Concepts.htm#numbers">整数</a></p>
    <p>设备的显示名称和/或索引. 例如, <code>1</code>, <code>"Speakers"</code>, <code>"Speakers:2"</code> 或 <code>"Speakers (Example HD Audio)"</code>.</p>
    <p>如果省略该参数, 则它默认为系统的默认回放设备(不一定是设备 1).</p>
    <p>有关详情, 请参阅 <a href="Sound.htm#device">Device (Sound 函数)</a>.</p>
  </dd>

</dl>

<h2 id="Error_Handling">错误处理</h2>
<p>失败时可能会抛出以下异常之一:</p>
<table class="info">
  <tr><th abbr="Class">Error 类</th><th>消息</th></tr>
  <tr><td rowspan="3"><a href="Error.htm#TargetError">TargetError</a></td><td>Device not found(无法找到设备)</td></tr>
  <tr><td>Component not found(无法找到组件)</td></tr>
  <tr><td>Component doesn't support this control type(组件不支持此控件类型)</td></tr>
  <tr><td><a href="Error.htm#OSError">OSError</a></td><td><em>System-generated.(由系统生成)</em></td></tr>
</table>

<h2 id="Remarks">备注</h2>
<p>切换默认回放设备的主静音设置的另一种方法是让脚本发送一个击键, 如下例所示:</p>
<pre>Send "{Volume_Mute}"  <em>; 静音/不静音主音量.</em></pre>
<p>要发现系统上安装的声音设备的功能 -- 比如名称和可用的组件 -- 请运行这个<a href="Sound.htm#ExSoundcard">声卡分析脚本</a>.</p>
<p>使用 <a href="SoundGetMute.htm">SoundGetMute</a> 来获取当前静音设置.</p>

<h2 id="Related">相关</h2>
<p><a href="Sound.htm">Sound 函数</a></p>

<h2 id="Examples">示例</h2>
<div class="ex" id="ExMasterMute">
<p><a class="ex_number" href="#ExMasterMute"></a> 设置主音量静音(开启静音).</p>
<pre>SoundSetMute true</pre>
</div>

<div class="ex" id="ExToggleMute">
<p><a class="ex_number" href="#ExToggleMute"></a> 切换主静音(设置到相反的状态).</p>
<pre>SoundSetMute -1</pre>
</div>

<div class="ex" id="ExLineInMute">
<p><a class="ex_number" href="#ExLineInMute"></a> 静音 Line In.</p>
<pre>SoundSetMute 1, "Line In"</pre>
</div>

<div class="ex" id="ExMicRecordMute">
<p><a class="ex_number" href="#ExMicRecordMute"></a> 静音麦克风录音.</p>
<pre>SoundSetMute 1, , "Microphone"</pre>
</div>

</div>
</body>
</html>